package com.ysqcould.web.controller.approval;


import com.ysqcould.approval.domain.Synergy;
import com.ysqcould.approval.domain.vo.SynergyVo;
import com.ysqcould.approval.service.ISynergyService;
import com.ysqcould.common.annotation.Log;
import com.ysqcould.common.core.controller.BaseController;
import com.ysqcould.common.core.domain.AjaxResult;
import com.ysqcould.common.core.page.TableDataInfo;
import com.ysqcould.common.enums.BusinessType;
import com.ysqcould.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 协同办公Controller
 * 
 * @author ruoyi
 * @date 2022-06-29
 */
@RestController
@RequestMapping("/approval/synergy")
public class SynergyController extends BaseController
{
    @Autowired
    private ISynergyService synergyService;

    /**
     * 查询协同办公列表
     */
    @PreAuthorize("@ss.hasPermi('approval:synergy:list')")
    @GetMapping("/list")
    public TableDataInfo list(Synergy synergy)
    {
        startPage();
        List<SynergyVo> list = synergyService.selectSynergyList(synergy);
        return getDataTable(list);
    }



    /**
     * 获取协同办公详细信息
     */
    @PreAuthorize("@ss.hasPermi('approval:synergy:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(synergyService.selectSynergyById(id));
    }

    /**
     * 新增协同办公
     */
    @PreAuthorize("@ss.hasPermi('approval:synergy:add')")
    @Log(title = "协同办公", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Synergy synergy)
    {
        synergy.setAsId(getUserId());
        return toAjax(synergyService.insertSynergy(synergy));
    }

    /**
     * 修改协同办公
     */
    @PreAuthorize("@ss.hasPermi('approval:synergy:edit')")
    @Log(title = "协同办公", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Synergy synergy)
    {
        return toAjax(synergyService.updateSynergy(synergy));
    }

    /**
     * 删除协同办公
     */
    @PreAuthorize("@ss.hasPermi('approval:synergy:remove')")
    @Log(title = "协同办公", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(synergyService.deleteSynergyByIds(ids));
    }
}
